package com.agileai.bpm.controller.define;

import java.util.List;

import com.agileai.bpm.bizmoduler.emulation.SingleProcessListSelect;
import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.controller.core.PickFillModelHandler;
import com.agileai.hotweb.renders.DispatchRenderer;
import com.agileai.hotweb.renders.LocalRenderer;
import com.agileai.hotweb.renders.ViewRenderer;

public class WfProcessCodeSelectHandler
        extends PickFillModelHandler {
    public WfProcessCodeSelectHandler() {
        super();
        this.serviceId = buildServiceId(SingleProcessListSelect.class);
    }

	public ViewRenderer prepareDisplay(DataParam param){
		mergeParam(param);
		initParameters(param);
		this.setAttributes(param);
		List<DataRow> rsList = getService().findProcessCodeList(param);
		this.setRsList(rsList);
		this.setAttribute(param, "fromHandlerId");
		return new LocalRenderer(getPage());
	}
	protected void initParameters(DataParam param) {
        initParamItem(param, "wfpName", "");
        initParamItem(param, "wfpCode", "");
    }
	public ViewRenderer doSelectAction(DataParam param){
		String fromHandlerId = param.get("fromHandlerId");
		return new DispatchRenderer(getHandlerURL(fromHandlerId));
	}
	public ViewRenderer doBackAction(DataParam param){
		String fromHandlerId = param.get("fromHandlerId");
		return new DispatchRenderer(getHandlerURL(fromHandlerId));
	}

    protected SingleProcessListSelect getService() {
        return (SingleProcessListSelect) this.lookupService(this.getServiceId());
    }
}
